﻿
namespace EasyNet.Solr.Commons.Params
{
    /// <summary>
    /// Parameters used for spellchecking
    /// </summary>
    public struct SpellingParams
    {
        public const string SPELLCHECK_PREFIX = "spellcheck.";

        /// <summary>
        /// The name of the dictionary to be used for giving the suggestion for a
        /// request. The value for this parameter is configured in solrconfig.xml
        /// </summary>
        public const string SPELLCHECK_DICT = SPELLCHECK_PREFIX + "dictionary";

        /// <summary>
        /// The count of suggestions needed for a given query.
        /// <p/>
        /// If this parameter is absent in the request then only one suggestion is
        /// returned. If it is more than one then a maximum of given suggestions are
        /// returned for each token in the query.
        /// </summary>
        public const string SPELLCHECK_COUNT = SPELLCHECK_PREFIX + "count";

        /// <summary>
        /// When this parameter is set to true and the misspelled word exists in the
        /// user field, only words that occur more frequently in the Solr field than
        /// the one given will be returned. The default value is false.
        /// <p/>
        /// <b>This is applicable only for dictionaries built from Solr fields.</b>
        /// </summary>
        public const string SPELLCHECK_ONLY_MORE_POPULAR = SPELLCHECK_PREFIX + "onlyMorePopular";

        /// <summary>
        /// Whether to use the extended response format, which is more complicated but
        /// richer. Returns the document frequency for each suggestion and returns one
        /// suggestion block for each term in the query string. Default is false.
        /// <p/>
        /// <b>This is applicable only for dictionaries built from Solr fields.</b>
        /// </summary>
        public const string SPELLCHECK_EXTENDED_RESULTS = SPELLCHECK_PREFIX + "extendedResults";

        /// <summary>
        /// Use the value for this parameter as the query to spell check.
        /// <p/>
        /// This parameter is <b>optional</b>. If absent, then the q parameter is
        /// used.
        /// </summary>
        public const string SPELLCHECK_Q = SPELLCHECK_PREFIX + "q";

        /// <summary>
        /// Whether to build the index or not. Optional and false by default.
        /// </summary>
        public const string SPELLCHECK_BUILD = SPELLCHECK_PREFIX + "build";

        /// <summary>
        /// Whether to reload the index. Optional and false by default.
        /// </summary>
        public const string SPELLCHECK_RELOAD = SPELLCHECK_PREFIX + "reload";

        /// <summary>
        /// Take the top suggestion for each token and create a new query from it
        /// </summary>
        public const string SPELLCHECK_COLLATE = SPELLCHECK_PREFIX + "collate";

        /// <summary>
        /// <p>
        /// The maximum number of collations to return.  Default=1.  Ignored if "spellcheck.collate" is false.
        /// </p>
        /// </summary>
        public const string SPELLCHECK_MAX_COLLATIONS = SPELLCHECK_PREFIX + "maxCollations";

        /// <summary>
        /// <p>
        /// The maximum number of collations to test by querying against the index.
        /// When testing, the collation is substituted for the original query's "q" param.  Any "qf"s are retained.
        /// If this is set to zero, does not test for hits before returning collations (returned collations may result in zero hits).
        /// Default=0. Ignored of "spellcheck.collate" is false.
        /// </p>
        /// </summary>
        public const string SPELLCHECK_MAX_COLLATION_TRIES = SPELLCHECK_PREFIX + "maxCollationTries";

        /// <summary>
        /// <p>
        /// The maximum number of word correction combinations to rank and evaluate prior to deciding which collation
        /// candidates to test against the index.  This is a performance safety-net in cases a user enters a query with
        /// many misspelled words.  The default is 10,000 combinations.
        /// </p>
        /// </summary>
        public const string SPELLCHECK_MAX_COLLATION_EVALUATIONS = SPELLCHECK_PREFIX + "maxCollationEvaluations";

        /// <summary>
        /// <p>
        /// Whether to use the Extended Results Format for collations.
        /// Includes "before>after" pairs to easily allow clients to generate messages like "no results for PORK.  did you mean POLK?"
        /// Also indicates the # of hits each collation will return on re-query.  Default=false, which retains 1.4-compatible output.
        /// </p>
        /// </summary>
        public const string SPELLCHECK_COLLATE_EXTENDED_RESULTS = SPELLCHECK_PREFIX + "collateExtendedResults";

        /// <summary>
        /// Certain spelling implementations may allow for an accuracy setting.
        /// </summary>
        public const string SPELLCHECK_ACCURACY = SPELLCHECK_PREFIX + "accuracy";
    }
}
